import { useState } from "react";

function App() {
    /**
     * setState更新state 数据是同步更新还是异步更新?
     * setCount(count +1)是异步更新的
     * 如果想要数据达到同步更新的效果:
     * setCount((count) => {
     * return count +1;
     * })
     */

    const [count,setCount] = useState(0);

    const handleClick =() => {
        setCount((count) => {
            //return 会结束代码
            return count +1;
        }) ;
    }

    return 
    <div>
        <button onClick={handleClick}>点击次数</button>
    </div>
};

export default App;